﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using DataModel;
using P_PersonalDetails.Service.ContactNumbers;
namespace P_PersonalDetails
{
    public partial class ContactNumbers : UserControl
    {
        public ContactNumbers()
        {
            InitializeComponent();
            try
            {
                SRV.LoadContactDetailsCompleted += new EventHandler<LoadContactDetailsCompletedEventArgs>(SRV_LoadContactDetailsCompleted);
            }
            catch (Exception)
            {
            }
        }

        void SRV_LoadContactDetailsCompleted(object sender, LoadContactDetailsCompletedEventArgs e)
        {
            this.DataContext = e.Result;
        }

        public int? MemberID
        {
            get { return (int?)GetValue(MemberIDProperty); }
            set { SetValue(MemberIDProperty, value); }
        }

        // Using a DependencyProperty as the backing store for MemberID.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty MemberIDProperty =
            DependencyProperty.Register("MemberID", typeof(int?), typeof(ContactNumbers), new PropertyMetadata(null, (DO, DE) =>
            {
                if (DE.NewValue != null)
                {
                    ((ContactNumbers)DO).MemberIDChanged();
                }
            }));

        void MemberIDChanged()
        {
            SRV.LoadContactDetailsAsync(MemberID.Value);
        }



        ContactNumbersServiceClient SRV = ServiceConfig.NewContactNumbersClient();
    }
}
